﻿// ---------------------------------------------------------------------
// Partial của lớp SSupervisor
//
// Nội dung:
//    + Các hàm xử lý lúc bắt đầu game
//
// Copyright (c) 2009 YugiOH
//
// Nguyễn Hữu Lê Trọng Tín      YM: ilu2009             ĐT: 0906520611 
// Võ Phước Hậu                 YM: phuochauspkt        ĐT: 0979202707
// ---------------------------------------------------------------------


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace ServerYuGi
{
    public partial class SSupervisor
    {
        int demPlayerBegin = 0;
        void Process_PLAYER_LOGIN(params object[] param)
        {           
            Players[demPlayerBegin].ID = (int)param[0];            
            Console.WriteLine("Player login: ID = " + Players[demPlayerBegin].ID);
            Players[demPlayerBegin].SoBaiChuaChia.Clear();
            Console.WriteLine("Start Get Card");
            //List<int> cards = yugiService.GetAllCard(Players[demPlayerBegin].ID).Deck;
            //Console.WriteLine("Card of Player {0} : Count = {1}", Players[demPlayerBegin].ID, cards.Count);
            List<int> cards = new List<int>();
            if(cards.Count==0)
            {
                cards = Fake_Card_Deck[(int)param[0]];
              
            }
            foreach (int i in cards)
            {
                Players[demPlayerBegin].AddCardToBoBaiChuaChia(i);
            }
            Players[demPlayerBegin].ID = demPlayerBegin;
            demPlayerBegin++;           
            Console.WriteLine("So luong player Begin: " + demPlayerBegin.ToString());
            if(demPlayerBegin == 2)
                CheckBatDauVanMoi();
        }

        void CheckBatDauVanMoi()
        {
            if (Players.Count == 2)
            {
                Console.WriteLine("Bat Dau Van");
                BatDauVan();
            }
        }
    }
}
